<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>用户列表</title>

    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{lib/css/main.css}">
    <link rel="stylesheet" th:href="@{/lib/css/public.css}">

    <script th:src="@{/lib/js/jquery-3.4.1.min.js}"></script>
    <script th:src="@{/layui/layui.js}"></script>


</head>

<style>
.center{
    margin-left: 30%;
    margin-top:20px;
}
.layui-form{
    width: 500px;
}
.title{
    text-align: center;
    color:grey;
}
body{
    background-image: url("images/background/page_bg.JPG");
    background-size: 100%;

}
</style>
<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function(){
        var element = layui.element;

        //…
    });
</script>
<body>
<!--<div th:replace="menu/left :: leftbar" ></div>-->
<!--<div th:replace="menu/top :: topbar"></div>-->
<div class="center">
    <div class="form">
        <br>
        <form class="layui-form" th:action="@{/user/edit}" method="post">
            <h1 class="title">用户信息修改</h1>
            <hr class="layui-bg-green">
            <div class="layui-form-item">
                <label class="layui-form-label">用户名:</label>
                <input type="hidden" name="uid" th:value="${user.uid}">
                <div class="layui-input-block">
                    <input type="text" name="username" lay-verify="username"  th:value="${user.username}" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码:</label>
                <div class="layui-input-block">
                    <input type="text" name="password" lay-verify="password"  th:value="${user.password}" autocomplete="off" class="layui-input">

                </div>

            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">性别:</label>
                <div class="layui-input-block">
                    <input type="radio" name="gender" value="man" title="男" checked="">
                    <input type="radio" name="gender" value="woman" title="女">

                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">邮箱:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="email" lay-verify="email" autocomplete="off" th:value="${user.email}" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">

                <div class="layui-inline">
                    <label class="layui-form-label">出生日期:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="birthday" id="date" lay-verify="date" th:value="${user.birthday}" autocomplete="off" class="layui-input">
                    </div>
                </div>

            </div>


            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">学号(选填):</label>
                <div class="layui-input-block">
                    <input th:value="${user.activeCode}" name="activeCode" class="layui-input"></input>
                </div>
            </div>
            <br>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-radius layui-btn-normal" lay-submit="" lay-filter="demo1">修改</button>
                    &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;
                    <button type="reset" class="layui-btn layui-btn-radius  layui-btn-danger">重置</button>
                </div>
            </div>
            <br>
        </form>
</div>
    <script>
        layui.use(['form', 'layedit', 'laydate'], function(){
            var form = layui.form
                ,layer = layui.layer
                ,layedit = layui.layedit
                ,laydate = layui.laydate;

            //日期
            laydate.render({
                elem: '#date'
            });


            //创建一个编辑器
            var editIndex = layedit.build('LAY_demo_editor');

            //自定义验证规则
            form.verify({
                title: function(value){
                    if(value.length < 5){
                        return '标题至少得5个字符啊';
                    }
                }
                ,password: [
                    /^[\S]{6,12}$/
                    ,'密码必须6到12位，且不能出现空格'
                ]
                ,username:[
                    /^[\S]{2,}$/
                    ,'用户名长度必须大于2，且不能出现空格'
                ]
                ,content: function(value){
                    layedit.sync(editIndex);
                }
            });


        });
    </script>
</body>

</html>